package me.zhengjie.utils;

import lombok.Data;
import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    private Boolean success;
    private String message;
    private T data;
    private Long total;
    private Integer page;
    private Integer limit;

    private Result() {}

    public static <T> Result<T> ok() {
        Result<T> result = new Result<>();
        result.setSuccess(true);
        return result;
    }

    public static <T> Result<T> ok(T data) {
        Result<T> result = new Result<>();
        result.setSuccess(true);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> ok(T data, Long total, Integer page, Integer limit) {
        Result<T> result = new Result<>();
        result.setSuccess(true);
        result.setData(data);
        result.setTotal(total);
        result.setPage(page);
        result.setLimit(limit);
        return result;
    }

    public static <T> Result<T> error(String message) {
        Result<T> result = new Result<>();
        result.setSuccess(false);
        result.setMessage(message);
        return result;
    }

    public Result<T> message(String message) {
        this.setMessage(message);
        return this;
    }

    public Result<T> data(T data) {
        this.setData(data);
        return this;
    }
} 